package com.ayu.a.practice02;

/**
 * @Author 徐林玉
 * @Description IsPalindromePrac
 * @Date 2022/11/15 11:23
 * @Version 1.0
 */
public class IsPalindromePrac {

    public static void main(String[] args) {

        String s = "A man, a plan, a canal: Panama";

        boolean palindrome = isPalindrome(s);

        System.out.println("palindrome = " + palindrome);


    }


    public static boolean isPalindrome(String d){


        String s1 = d.replaceAll("[^a-zA-Z0-9]", "");

        char[] s = s1.toCharArray();

        char temp = ' ';

        for (int i = 0; i < s.length/2; i++) {


            temp = s[i];

            s[i] = s[s.length-i-1];

            s[s.length-i-1] = temp;

        }


        String s2 = String.valueOf(s);


        return s1.equalsIgnoreCase(s2);


    }
}
